/*
@Author   : Uyynot
@Email    : uyynot@qq.com
@Time     : 2023/10/18 13:59
@File     : server.go
@Project  : GoProject
@Desc     :
*/
package server

import (
	"GoProject/internal/handler"
	"GoProject/internal/pkg/middleware"
	"GoProject/internal/router"
	"GoProject/pkg/log"
	"github.com/gin-gonic/gin"
)

type Server struct {
	ServerHttp *gin.Engine
}

func NewServer(logger *log.Logger, userHandler handler.UserHandler) *Server {
	r := gin.New()
	//设置统一请求/响应日志
	r.Use(middleware.ResponseLogMiddleware(logger), middleware.RequestLogMiddleware(logger))
	defaultRouter := router.RouterGroupApp
	//初始化user路由
	defaultRouter.InitUserRouter(&r.RouterGroup, userHandler)
	return &Server{ServerHttp: r}
}
